{% extends "home_base.html" %}
{% load seahub_tags i18n %}
{% load url from future %}

{% block sub_title %}{% trans "Files - Share" %} - {% endblock %}

{% block cur_share_files %}tab-cur{% endblock %}

{% block right_panel %}
<div id="tabs" class="tab-tabs">
    <ul class="tab-tabs-nav hd w100 ovhd">
        <li class="tab"><a href="#priv-share-in" class="a">{% trans "From Others" %}</a></li>
        {% if user.permissions.can_add_repo %}
        <li class="tab long-tab"><a href="#priv-share-out" class="a">{% trans "To Others" %}</a></li>
        {% endif %}
    </ul>
    <div id="priv-share-in">
        {% if priv_share_in %}
        <table>
            <tr>
                <th width="5%"><!--icon--></th>
                <th width="40%">{% trans "Name" %}</th>
                <th width="25%">{% trans "Library" %}</th>
                <th width="18%">{% trans "From" %}</th>
                <th width="12%">{% trans "Operations" %}</th>
            </tr>
            {% for e in priv_share_in %}
            <tr>
                {% if e.s_type == 'f' %}
                <td class="alc"><img src="{{ MEDIA_URL }}img/file/{{ e.file_or_dir|file_icon_filter }}" alt="" /></td>
                <td><a href="{% url 'view_priv_shared_file' e.token %}?p={{ e.path|urlencode}}">{{e.file_or_dir}}</a></td>
                {% else %}
                <td class="alc"><img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="" /></td>
                <td><a href="{% url 'repo' e.repo_id %}?p={{ e.path|urlencode}}">{{e.file_or_dir}}</a></td>
                {% endif %}
                <td>--</td>
                <td>{{e.from_user|email2nickname}}</td>
                <td>
                    <a href="{% url 'rm_private_file_share' e.token %}" class="op-icon vh" title="{% trans "Unshare" %}">
                        <img src="{{MEDIA_URL}}img/rm.png" alt="" />
                    </a>
                </td>
            </tr>
            {% endfor %}
        </table>
        {% else %}
        <div class="empty-tips">
            <h2 class="alc">{% trans "No file is shared to you" %}</h2>
            <p>{% trans "Single files shared to you will be listed here, and you can download them or save them to some libraries." %}</p>
        </div>
        {% endif %}
    </div>

    {% if user.permissions.can_add_repo %}
    <div id="priv-share-out" class="hide">
        {% if priv_share_out %}
        <table>
            <tr>
                <th width="5%"><!--icon--></th>
                <th width="40%">{% trans "Name"%}</th>
                <th width="25%">{% trans "Library"%}</th>
                <th width="18%">{% trans "To"%}</th>
                <th width="12%">{% trans "Operations"%}</th>
            </tr>
            {% for e in priv_share_out %}
            <tr>
                {% if e.s_type == 'f' %}
                <td class="alc"><img src="{{ MEDIA_URL }}img/file/{{ e.file_or_dir|file_icon_filter }}" alt="{% trans "File"%}" /></td>
                <td><a href="{% url 'view_priv_shared_file' e.token %}?p={{ e.path|urlencode}}">{{e.file_or_dir}}</a></td>
                {% else %}
                <td class="alc"><img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory icon"%}" /></td>
                <td><a href="{% url 'repo' e.repo_id %}?p={{ e.path|urlencode}}">{{e.file_or_dir}}</a></td>
                {% endif %}
                <td><a href="{% url 'repo' e.repo_id %}">{{e.repo.name}}</a></td>
                <td>{{e.to_user|email2nickname}}</td>
                <td>
                    <a href="{% url 'rm_private_file_share' e.token %}" class="op-icon vh" title="{% trans "Unshare" %}">
                        <img src="{{MEDIA_URL}}img/rm.png" alt="" />
                    </a>
                </td>
            </tr>
            {% endfor %}
        </table>
        {% else %}
        <div class="empty-tips">
            <h2 class="alc">{% trans "You don't have any private shared files" %}</h2>
            <p>{% trans "You can share a single file with a registered user if you don't want to share a whole library." %}</p>
        </div>
        {% endif %}
    </div>
    {% endif %}
</div>
{% endblock %}
